﻿#pragma once
namespace jz {
#include"HashTable.h"
	template<class K, class V, class Hash = HashFunc<K>>
	class unordered_map
	{
		struct map_keyoft
		{
			const K& operator()(const pair<K, V>& key)
			{
				return key.first;
			}
		};
	public:
		typedef typename HashTable<K, pair<K, V>, map_keyoft, Hash>::iterator iterator;
		iterator begin()
		{
			return u_map.begin();
		}
		iterator end()
		{
			return u_map.end();
		}
		bool insert(const pair<K, V>& kv)
		{
			return u_map.Insert(kv);
		}
	private:
		HashTable<K, pair<K, V>, map_keyoft, Hash> u_map;
	};
	void testmap()
	{
		unordered_map<string, string> dict;
		dict.insert(make_pair("sort", "排序"));
		dict.insert(make_pair("left", "向左"));
		dict.insert(make_pair("right", "向右"));
		for (auto e : dict)
		{
			cout << e.first << " : " << e.second << endl;
		}
		cout << endl;
	}

}